<div class="findtrs">
	<div class="ftitle">
		<div class="lt">
			<h2>财务明细</h2>
		</div>
	</div>

	<div class="funaduibi fbai qmbox1">
		<div class="form">
			<form action="" method="post">
				<ul class="clearfix">
					<li>
						<label>时间</label>
						<div class="bt">
							<input class="t1 t2" type="text" name="stime" id="stime" value="" placeholder="开始日期"/>
							<span><img src="__STATIC__/lib/index/images/qm18.png" ></span>
							<input class="t1 t2" type="text" name="ltime" id="ltime" value="" placeholder="结束日期"/>
						</div>
					</li>
					<li>
						<label>描述</label>
						<input class="t1" type="text" name="desc" id="desc" value="" placeholder="请输入描述"/>
					</li>
					<li>
						<div class="btn">
<!--							<a href="#" class="b1"><span>清空</span></a>-->
							<a href="#" class="b1 on" lay-submit lay-filter="*"><span>查询</span></a>
						</div>
					</li>
				</ul>
			</form>
		</div>
	</div>


	<div class="funaduibi fbai">
		<div class="fdbtable qmfdbtable" >
			<table border="0" cellspacing="0" cellpadding="0" width="100%" id="dataTable" >
			</table>
		</div>
	</div>

</div>
<script type="text/javascript">
	layui.use(['form', 'laydate', 'table',], function () {
		var laydate = layui.laydate,
				form = layui.form,
				table = layui.table; //表格

		//执行一个laydate实例
		laydate.render({
			elem: '#stime' //指定元素
		});
		laydate.render({
			elem: '#ltime' //指定元素
		});
		table.render({
			elem: '#dataTable',
			height: 'auto',
			cellMinWidth: '80',
			// totalRow: true,
			method: 'post',
			url: "{:url('fund/account')}",
			id: 'dataTable',
			text:{none: 'No Data'},
			error: function(){
				setTimeout("window.location.href='" + "{:url('index/index')}" + "'; ", 1000);
			},
			toolbar: '#toolbar', //开启头部工具栏，并为其绑定左侧模板
			defaultToolbar: ['filter', 'exports'],
			cols: [[
				{ type: 'numbers'},
				{ align: 'center', title: '操作时间', width: 180,
					templet: function (d) {
						return layui.util.toDateString(d.ctime * 1000, "yyyy-MM-dd HH:mm:ss");
					}
				},
				{ field: '', align: 'left', title: '类型' , width: 180,
					templet: function (d) {
						const type_name = d.type;
						if(type_name == 1){
							return '<font color="red">Debit</font>';
						}else{
							return '<font color="green">Credit</font>';
						}
					}
				},
				{field: 'amount', title: '金额($)', align:"left",
					style:'font-weight:bold',width:180,
					templet: function (d) {
						const type_name = d.type;
						if(type_name == 1){
							return ' - ' + d.amount;
						}else{
							return d.amount;
						}
					}
				},
				{ field: 'balance', align: 'left', title: '余额($)' ,width:180,
					style:'font-weight:bold'},
				{ field: 'desc',  align: 'left', title: '描述'},
				{ align: 'left', title: '类型', width:180,
					templet: function (d) {
						return 'Completed';
					}
				},
			]],
			page: true,
			limit: 10,
			limits: [10, 50, 100,1000],
		});
		form.on('submit(*)', function (data) {
			layui.table.reload('dataTable', {
				where: {
					stime:$("#stime").val(),
					ltime:$("#ltime").val(),
					desc:$("#desc").val()
				}
				, page: {
					curr: 1 //重新从第 1 页开始
				}
			});
			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		});
	});
</script>